﻿using System;
using EnvDTE;
using EnvDTE80;

namespace ForgeIt.Commands
{
    ///<summary>
    /// Command to be available for the SLN file of a VS project
    ///</summary>
    public class SlnCommand: BaseCommand
    {

        ///<summary>
        /// 
        ///</summary>
        ///<param name="applicationObject"></param>
        ///<param name="connectorClass"></param>
        public SlnCommand(DTE2 applicationObject, Connect connectorClass)
            : base(applicationObject, connectorClass)
        {
            validExtensions.Add(".sln");
        }

        public override void Exec(string CmdName, EnvDTE.vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled)
        {
            try
            {
                Log("Opening ApplicationManagerForm");
                // TODO: Implement Manager form
            }
            catch (Exception ex)
            {
                Log(ex);
            }
        }

        public override void QueryStatus(string CmdName, EnvDTE.vsCommandStatusTextWanted NeededText, ref EnvDTE.vsCommandStatus StatusOption, ref object CommandText)
        {
            try
            {
                base.QueryStatus(CmdName, NeededText, ref StatusOption, ref CommandText);

                if (ConnectorClass.ForgeSolution != null && string.IsNullOrEmpty(ConnectorClass.ForgeSolution.ServerConnectionString))
                    StatusOption = vsCommandStatus.vsCommandStatusInvisible;
            }
            catch (Exception ex)
            {
                Log(ex);
            }
        }
    }
}
